package com.walker.condition;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.StringUtils;

/**
 * @Description:
 * @ProjectName: walker-step
 * @Package: com.walker.condition
 * @ClassName: LinuxCondition
 * @Author: yangyl
 * @CreateDate: 2020/6/10 0:10
 */
public class LinuxCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        ClassLoader beanClassLoader = beanFactory.getBeanClassLoader();
        Environment environment = context.getEnvironment();
        System.out.println(environment.getProperty("os.name"));
        if("linux".equals(environment.getProperty("os.name"))){
            return true;
        }
        return false;
    }
}
